home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / AboutDialog.java < prev    next >
Encoding:
Java Source  |  1996-12-07  |  1.9 KB  |  72 lines

  1. /*
  2.     A basic extension of the java.awt.Dialog class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. public class AboutDialog extends Dialog {
  8.     void okButton_Clicked(Event event) {
  9.         //{{CONNECTION
  10.         // Clicked from okButton Hide the Dialog
  11.         hide();
  12.         //}}
  13.     }
  14.  
  15.     public AboutDialog(Frame parent, boolean modal) {
  16.  
  17.         super(parent, modal);
  18.  
  19.         //{{INIT_CONTROLS
  20.         setLayout(null);
  21.         addNotify();
  22.         resize(insets().left + insets().right + 335,insets().top + insets().bottom + 86);
  23.         setFont(new Font("Dialog", Font.BOLD, 12));
  24.         setForeground(new Color(0));
  25.         setBackground(new Color(16777215));
  26.         okButton = new java.awt.Button("OK");
  27.         okButton.reshape(insets().left + 128,insets().top + 48,72,26);
  28.         okButton.setFont(new Font("Dialog", Font.BOLD, 12));
  29.         add(okButton);
  30.         labelAbout = new java.awt.Label("Amazing Adventures Travel - Custom Itinerary Application");
  31.         labelAbout.reshape(insets().left + -8,insets().top + 8,344,31);
  32.         labelAbout.setFont(new Font("Dialog", Font.BOLD, 12));
  33.         labelAbout.setForeground(new Color(0));
  34.         labelAbout.setBackground(new Color(16777215));
  35.         add(labelAbout);
  36.         setTitle("About");
  37.         setResizable(false);
  38.         //}}
  39.     }
  40.  
  41.     public AboutDialog(Frame parent, String title, boolean modal) {
  42.         this(parent, modal);
  43.         setTitle(title);
  44.     }
  45.  
  46.     public synchronized void show() {
  47.         Rectangle bounds = getParent().bounds();
  48.         Rectangle abounds = bounds();
  49.  
  50.         move(bounds.x + (bounds.width - abounds.width)/ 2,
  51.              bounds.y + (bounds.height - abounds.height)/2);
  52.  
  53.         super.show();
  54.     }
  55.  
  56.     public boolean handleEvent(Event event) {
  57.         if(event.id == Event.WINDOW_DESTROY) {
  58.             hide();
  59.             return true;
  60.         }
  61.         if (event.target == okButton && event.id == Event.ACTION_EVENT) {
  62.             okButton_Clicked(event);
  63.         }
  64.         return super.handleEvent(event);
  65.     }
  66.  
  67.     //{{DECLARE_CONTROLS
  68.     java.awt.Button okButton;
  69.     java.awt.Label labelAbout;
  70.     //}}
  71. }
  72.